package io.renren.modules.generator.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.generator.entity.OtFriendRequestEntity;
import io.renren.modules.generator.service.OtFriendRequestService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

/**
 * 好友请求表
 * 
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2018-08-12 00:55:16
 */
@RestController
@RequestMapping("otfriendrequest")
public class OtFriendRequestController {
	@Autowired
	private OtFriendRequestService otFriendRequestService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("otfriendrequest:list")
	public R list(@RequestParam Map<String, Object> params){
        PageUtils page = otFriendRequestService.queryPage(params);

        return R.ok().put("page", page);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("otfriendrequest:info")
	public R info(@PathVariable("id") Integer id){
		OtFriendRequestEntity otFriendRequest = otFriendRequestService.selectById(id);
		
		return R.ok().put("otFriendRequest", otFriendRequest);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("otfriendrequest:save")
	public R save(@RequestBody OtFriendRequestEntity otFriendRequest){
		otFriendRequestService.insert(otFriendRequest);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("otfriendrequest:update")
	public R update(@RequestBody OtFriendRequestEntity otFriendRequest){
		otFriendRequestService.updateById(otFriendRequest);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("otfriendrequest:delete")
	public R delete(@RequestBody Integer[] ids){
		otFriendRequestService.deleteBatchIds(Arrays.asList(ids));
		
		return R.ok();
	}
	
}
